export const tcZ1: any = [
    {
        showRowGroup: 'hide_def',
        "headerName": "",
        "checkboxSelection": true,
        "headerCheckboxSelection": true,
        "pinned": "left",
        "width": 50,
        resizable: false,
        filter: false,
        sortable: false,
        minWidth: 50,
        maxWidth: 50,
        lockPosition: "left",
    },
    {
        headerName: '分缸',
        field: 'circulatCard',
        width: 1040,
        children: [
            {
                headerName: '缸型',
                field: 'dyeworkerUserCode',
                width: 130,
                rowSpan: param => {
                    return rowSpan(param);
                },
                cellClassRules: { 'cell-span': 'value !== undefined' },
            },
            {
                headerName: '管数',
                field: 'dyeworkerUserName',
                width: 130,
                rowSpan: param => {
                    return rowSpan(param);
                },
                cellClassRules: { 'cell-span': 'value !== undefined' },
            },
            {
                headerName: '开缸数',
                field: 'dyeworkerCoefficient',
                width: 130
            },
            {
                headerName: '布号',
                field: 'dyeworkerMoney',
                width: 130
            },
            {
                headerName: '色称',
                field: 'dyeworkerUserCode',
                width: 130
            },
            {
                headerName: '色号',
                field: 'dyeworkerUserName',
                width: 130
            },
            {
                headerName: '匹数',
                field: 'dyeworkerCoefficient',
                width: 130
            },
            {
                headerName: '重量',
                field: 'dyeworkerMoney',
                width: 130
            },
        ]
    },


]
export const tcZ2: any = [
    {
        showRowGroup: 'hide_def',
        "headerName": "",
        "checkboxSelection": true,
        "headerCheckboxSelection": true,
        "pinned": "left",
        "width": 50,
        resizable: false,
        filter: false,
        sortable: false,
        minWidth: 50,
        maxWidth: 50,
        lockPosition: "left",
    },
    {
        headerName: '分纱',
        field: 'circulatCard',
        width: 600,
        children: [
            {
                headerName: '缸数',
                field: 'dyeworkerUserCode',
                width: 120
            },
            {
                headerName: '匹数',
                field: 'dyeworkerUserName',
                width: 120
            },
            {
                headerName: '重量',
                field: 'dyeworkerCoefficient',
                width: 120
            },
            {
                headerName: '设备',
                field: 'dyeworkerMoney',
                width: 120
            },
            {
                headerName: '织厂',
                field: 'dyeworkerUserCode',
                width: 120
            },
            {
                headerName: '坯布编号',
                field: 'dyeworkerUserName',
                width: 120
            },
            {
                headerName: '纱批',
                field: 'dyeworkerCoefficient',
                width: 120
            },
            {
                headerName: '新增操作',
                field: 'dyeworkerCoefficient',
                width: 80
            },
        ]
    },
    {
        headerName: '库存',
        field: 'circulatCard',
        width: 600,
        children: [
            {
                headerName: '等级',
                field: 'dyeworkerUserCode',
                width: 120
            },
            {
                headerName: '机台',
                field: 'dyeworkerUserName',
                width: 120
            },
            {
                headerName: '匹数',
                field: 'dyeworkerCoefficient',
                width: 120
            },
            {
                headerName: '退批备注',
                field: 'dyeworkerMoney',
                width: 120
            },
            {
                headerName: '来料单号',
                field: 'dyeworkerUserCode',
                width: 120
            },
            {
                headerName: '库存匹数',
                field: 'dyeworkerUserName',
                width: 120
            },
            {
                headerName: '库存欠坯',
                field: 'dyeworkerCoefficient',
                width: 120
            },
            {
                headerName: '删除操作',
                field: 'dyeworkerCoefficient',
                width: 80
            },
        ]
    }


]
// function rowSpan(params) {
//     console.log(params, '111111111111111111')
//     var dyeworkerUserCode = params.data ? params.data.dyeworkerUserCode : undefined;
//     // var athlete = params.data.dyeworkerUserCode ? params.data.athlete : undefined;
//     console.log(dyeworkerUserCode, '2222222222222222222')
//     if (dyeworkerUserCode == '2') {
//         // have all Russia age columns width 2
//         return 2;
//     } else if (dyeworkerUserCode == '1') {
//         // have all United States column width 4
//         return 4;
//     } else {
//         // all other rows should be just normal
//         return 1;
//     }
// };


// const rowSpan = (params: any) => {
//     if (params.data.dyeworkerUserCode) {
//         return 4;
//     } else {
//         return 1;
//     }
// };

const rowSpan = (param: any) => {
    const arr = ["dyeworkerUserCode", "dyeworkerUserName"];
    if (arr.indexOf(param.column.colId) !== -1) {
        // 需要校验的字段
        const data = arr.slice(0, arr.indexOf(param.column.colId) + 1);
        // 每一条第一次出现时对应的索引
        const first = tableData.findIndex(item => {
            return data.every(v => item[v] === param.data[v]);
        });
        if (param.node.childIndex === first) {
            // 同一条出现的条数
            const rowspan = tableData.filter(item => {
                return data.every(v => item[v] === param.data[v]);
            }).length;
            return rowspan;
        } else {
            return 1;
        }
    }
},